﻿#region using statements

using Microsoft.Xna.Framework;
using System;

#endregion

namespace XNAGameEngine.Utility
{
    /// <summary>
    /// Miscellaneous Tools and Math Helpers
    /// </summary>
    public static class MathToolbox
    {
        private static Random _random = new Random();

        public static Random GetRandom { get { return _random; } private set { return; } }

        /// <summary>
        /// Adds a scalar value to both Vector2 values and returns the resulting
        /// vector
        /// </summary>
        /// <param name="vectorIn">the vector value</param>
        /// <param name="scalarIn">the scalar value</param>
        /// <returns></returns>
        public static Vector2 AddScalarToVector2(Vector2 vectorIn, float scalarIn)
        {
            vectorIn.X += scalarIn;
            vectorIn.Y += scalarIn;
            return vectorIn;
        }


        /// <summary>
        /// Multiplies a Vector2 object by a scalar and returns the value
        /// </summary>
        /// <param name="vectorIn">Vector2 object</param>
        /// <param name="scalarIn">scalar value</param>
        /// <returns>Vector2 * scalar</returns>
        public static Vector2 MultVector2ByScalar(
            Vector2 vectorIn, float scalarIn)
        {
            return new Vector2(vectorIn.X * scalarIn, vectorIn.Y * scalarIn);
        }

        /// <summary>
        /// Multiplies a Vector2 object by a scalar and returns the value
        /// </summary>
        /// <param name="vectorIn">Vector2 object</param>
        /// <param name="scalarIn">scalar value</param>
        /// <returns>Vector2 * scalar</returns>
        public static Vector2 MultVector2ByScalar(
            Vector2 vectorIn, int scalarIn)
        {
            return new Vector2(vectorIn.X * scalarIn, vectorIn.Y * scalarIn);
        }

        /// <summary>
        /// Adds the values of the two Vector2 objects passed in and returns a
        /// a new vector containing the sum of them
        /// </summary>
        /// <param name="one">the first vector</param>
        /// <param name="two">the second vector</param>
        /// <returns></returns>
        public static Vector2 AddVectors(Vector2 one, Vector2 two){
            return new Vector2(one.X + two.X, one.Y + two.Y);
        }

        /// <summary>
        /// Subtracts the values of the two Vector2 objects passed in and returns a
        /// a new vector containing the difference of them
        /// </summary>
        /// <param name="one">the first vector</param>
        /// <param name="two">the second vector</param>
        /// <returns></returns>
        public static Vector2 SubtractVectors(Vector2 one, Vector2 two)
        {
            return new Vector2(one.X - two.X, one.Y - two.Y);
        }
    }
}